package cn.lijigou.shopping;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.DuplicateFormatFlagsException;
import java.util.Timer;
import java.util.TimerTask;

import cn.lijigou.shopping.domain.API;
import cn.lijigou.shopping.service.CrashHandler;
import cn.lijigou.shopping.service.LocationService;
import cn.lijigou.shopping.service.MSystem;
import cn.lijigou.shopping.service.PushListener;
import cn.lijigou.shopping.util.Util;
 
import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.PendingIntent;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.DialogInterface.OnDismissListener;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.graphics.drawable.BitmapDrawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Parcelable;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

public class WelcomeActivity extends MActivity {
	
	public  static Dialog mDialog;
	public static final int IS_VERSION = 0;
	public static final int NOT_VERSION = 1;
	
 
	public static int push = 2;
//	private Process proc;
//	private LogOutputThread logThread;
//	public static StringBuffer mLog = new StringBuffer("");
//	public static String IMEI = "";
//	public static String SoftWareVersion="";
 
	
	public Handler mHander = new Handler(){
		@Override
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			if(msg.what==0){
			        Intent mIntent  = new Intent(WelcomeActivity.this,MainTabActivity.class);
			        startActivity(mIntent);
			        WelcomeActivity.this.finish();
			}
		}
	};
	 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   
                WindowManager.LayoutParams.FLAG_FULLSCREEN); 
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
        setContentView(R.layout.welcome);
        overridePendingTransition(R.anim.push_in,R.anim.push_out);
        push=1;
        //定位
        LocationService locationService = new LocationService(WelcomeActivity.this);
		locationService.start();
		mHander.sendEmptyMessageDelayed(0, 2000);
		if(getNetConnectState(WelcomeActivity.this)){
    		Intent intetns=new Intent(WelcomeActivity.this,PushListener.class);//
			intetns.setAction("cn.lookoo.setTimer");
			this.sendBroadcast(intetns);
	}
		
		
		
		
    }
	 private boolean alarmIsSet(Intent intent,Context context) {       
		 return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_NO_CREATE) != null;       
	 } 
	public boolean getNetConnectState(Context context) {
		boolean netConnect = false;
		ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo info = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		NetworkInfo infoM = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
		if (info.isConnected() || infoM.isConnected()) {
			netConnect = true;
		}
		return netConnect;
	}
 
 
 
 
}